{{post-gap post=this postStream=controller.model.postStream before="true"}}

<div class='row'>
  {{view 'reply-history' content=replyHistory}}
</div>

<article {{bind-attr class=":boxed via_email" id="postElementId" data-post-id="id" data-user-id="user_id"}}>
  <div class='row'>

    <div class='topic-avatar'>
      <div class="contents">
        {{#if userDeleted}}
          <i class="fa fa-trash-o deleted-user-avatar"></i>
        {{else}}
          {{raw "post/poster-avatar" post=this classNames="main-avatar"}}
        {{/if}}
        {{plugin-outlet "poster-avatar-bottom"}}
      </div>
    </div>

    <div class='topic-body'>
      <div class='topic-meta-data'>
        {{poster-name post=this}}
        <div class='post-info'>
          <a class='post-date' {{bind-attr href="shareUrl" data-share-url="shareUrl" data-post-number="post_number"}}>{{age-with-tooltip created_at}}</a>
        </div>
        {{#if hasHistory}}
          <div class='post-info edits'>
            {{#if can_view_edit_history}}
              <a href class="{{unbound view.historyHeat}}" {{action "showHistory" this}} title="{{i18n 'post.last_edited_on'}} {{raw-date updated_at}}">
                {{editCount}}
                {{fa-icon "pencil"}}
              </a>
            {{else}}
              <span class="{{unbound view.historyHeat}}" title="{{i18n 'post.last_edited_on'}} {{raw-date updated_at}}">
                {{editCount}}
                {{fa-icon "pencil"}}
              </span>
            {{/if}}
          </div>
        {{/if}}
        {{#if wiki}}
          <div class="post-info wiki" title="{{i18n 'post.wiki.about'}}" {{action "editPost" this}}>{{fa-icon "pencil-square-o"}}</div>
        {{/if}}
        {{#if via_email}}
          {{#if canViewRawEmail}}
            <div class="post-info via-email raw-email" title="{{i18n 'post.via_email'}}" {{action "showRawEmail" this}}>{{fa-icon "envelope-o"}}</div>
          {{else}}
            <div class="post-info via-email" title="{{i18n 'post.via_email'}}">{{fa-icon "envelope-o"}}</div>
          {{/if}}
        {{/if}}
        {{#if showUserReplyTab}}
          <a href {{action "toggleReplyHistory" this target="view"}} class='reply-to-tab'>
            {{#if loadingReplyHistory}}
              {{i18n 'loading'}}
            {{else}}
              {{fa-icon "mail-forward"}}
              {{avatar reply_to_user imageSize="tiny"}}
              <span>{{reply_to_user.username}}</span>
            {{/if}}
          </a>
        {{/if}}
        <div {{bind-attr class=":read-state read"}} title="{{i18n 'post.unread'}}">{{fa-icon "circle"}}</div>
      </div>

      <div {{bind-attr class=":select-posts controller.multiSelect::hidden"}}>
        <button {{action "toggledSelectedPostReplies" this}} {{bind-attr class="view.canSelectReplies::hidden"}}>{{i18n 'topic.multi_select.select_replies'}}</button>
        <button {{action "toggledSelectedPost" this}} class="select-post">{{view.selectPostText}}</button>
      </div>

      <!-- keep the classes here in sync with composer.hbs -->
      <div {{bind-attr class="showUserReplyTab:avoid-tab view.repliesShown::contents :regular view.extraClass"}}>
        <div class='cooked'>
          {{{cooked}}}
          {{#if firstPost}}
            {{plugin-outlet "topic-after-cooked"}}
          {{/if}}
        </div>
        {{#if cooked_hidden}}
          <a href {{action "expandHidden" this}}>{{i18n 'post.show_hidden'}}</a>
        {{/if}}
        {{#if view.showExpandButton}}
          {{#if controller.loadingExpanded}}
            <button class="btn expand-post" disabled>{{i18n 'loading'}}</button>
          {{else}}
            <button {{action "expandFirstPost" this}} class='btn expand-post'>{{i18n 'post.show_full'}}&hellip;</button>
          {{/if}}
        {{/if}}
        {{view 'post-menu' post=this adminMenu=view.adminMenu}}
      </div>

      {{#if replies}}
        <section class='embedded-posts bottom'>
          {{#each reply in replies}}
            {{view 'embedded-post' content=reply}}
          {{/each}}
        </section>
      {{/if}}

      {{discourse-action-history post=this}}
      {{view 'topic-map-container' post=this topic=controller.model}}
    </div>

    {{post-gutter post=this
                  links=internalLinks
                  canReplyAsNewTopic=topic.details.can_reply_as_new_topic
                  newTopicAction="replyAsNewTopic"}}
  </div>

</article>

{{post-gap post=this postStream=controller.model.postStream before="false"}}
